package com.swz.dcrm.ui;

import androidx.fragment.app.Fragment;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.swz.dcrm.R;
import com.swz.dcrm.adpter.FragmentViewPagerAdapter;
import com.swz.dcrm.digger.AppModule;
import com.swz.dcrm.digger.DaggerAppComponent;
import com.swz.dcrm.ui.base.BaseActivity;
import com.xh.baselibrary.widget.ClickImageView;
import com.xh.baselibrary.widget.NoScrollViewPager;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class PwdResetActivity extends BaseActivity {

    @BindView(R.id.toolbar_title)
    TextView title;
    @BindView(R.id.view_pager)
    NoScrollViewPager viewPager;
    @BindView(R.id.iv_state)
    ImageView ivState;
    @BindView(R.id.tv_right)
    TextView tvRight;
    @BindView(R.id.iv_back)
    ClickImageView ivBack;

    private List<Fragment> fragments;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_pwd_reset);
        ButterKnife.bind(this);
        View decorView = getWindow().getDecorView();
        decorView.setSystemUiVisibility(decorView.getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);

        title.setText(getString(R.string.reset_title));
        tvRight.setText(getString(R.string.reset_next_step));
        DaggerAppComponent.builder().appModule(new AppModule(this))
                .build().inject(this);
        fragments=new ArrayList<>();
        fragments.add(PwdResetStep1Fragment.newInstance());
        fragments.add(PwdResetStep2Fragment.newInstance());
        fragments.add(SuccessFragment.newInstance());
        List<String> titles=new ArrayList<>();
        titles.add("");
        titles.add("");
        titles.add("");
        viewPager.setAdapter(new FragmentViewPagerAdapter(getSupportFragmentManager(),fragments,titles));
        ivState.setImageDrawable(getResources().getDrawable(R.mipmap.resetpw_1));
        tvRight.setOnClickListener(v -> {

            Log.i("viewPager",viewPager.getCurrentItem()+"");
            if(viewPager.getCurrentItem()!=2){
                viewPager.setCurrentItem(viewPager.getCurrentItem()+1);
            }

                if(viewPager.getCurrentItem()==1){
                    ivState.setImageDrawable(getResources().getDrawable(R.mipmap.resetpw_2));
                }else {
                    ivState.setImageDrawable(getResources().getDrawable(R.mipmap.resetpw_3));
                }




        });
        viewPager.setCurrentItem(0);
        ivBack.setImageResource(R.mipmap.close);
        ivBack.setOnClickListener(v -> {
            this.finish();
        });
    }
}
